/*
     Copyright 2007 Joseph M. Ferner

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using OpenServers.Net.FtpServer.State;

namespace OpenServers.Net.FtpServer.Command {
    /// <summary>
    ///     <para>
    ///         <b>NOOP (NOOP)</b><br/>
    ///         This command does not affect any parameters or previously
    ///         entered commands. It specifies no action other than that the
    ///         server send an OK reply.
    ///     </para>
    ///     <para>
    ///         <b>Format</b><br/>
    ///         <code>NOOP &lt;CRLF&gt;</code>
    ///     </para>
    ///     <para>
    ///         <b>Success:</b>
    ///         <list type="bullet">
    ///             <item><term>200</term><description>Command okay.</description></item>
    ///         </list>
    ///     </para>
    ///     <para>
    ///         <b>Errors:</b>
    ///         <list type="bullet">
    ///             <item><term>421</term><description>Service not available, closing control connection.</description></item>
    ///             <item><term>500</term><description>Syntax error, command unrecognized.</description></item>
    ///         </list>
    ///     </para>
    /// </summary>
    public class NoOpCommand : BaseCommand {
        /// <summary>
        /// Does nothing.
        /// </summary>
        public override void PerformCommand(IFtpServer server, FtpState state, string arguments) {
            if (!string.IsNullOrEmpty(arguments)) {
                state.Listener.Send(state, server.Messages.Get501());
            } else {
                state.Listener.Send(state, server.Messages.Get200());
            }
        }
    }
}
